﻿@model BussinessLogic.Models.Administrator.UserDetails
@{
    ViewBag.Title = "UserDetails";
}
<fieldset>
    <legend>@Model.FirstName @Model.LastName</legend>
    <p>
        Active: @(Model.Active ? "Yes" : "No")
        |
        @if (Model.Active)
        {
            @Html.ActionLink("Lock account", "LockAccount", new { id = Model.ID })
        }
        else
        {
            @Html.ActionLink("Unlock account", "UnlockAccount", new { id = Model.ID })
        }
    </p>
    <p>
        Phone: @Model.Phone<br />
        Email: @Model.Email
    </p>

    <br />
    @if (Model.Studies.Count != 0)
    {
        
        <table>
            <tr>
                <th>
                    Study
                </th>
                <th>
                    State
                </th>
            </tr>
            @foreach (var item in Model.Studies)
            {
                <tr>
                    <td>
                        @Html.DisplayFor(modelItem => item.StudyName)
                    </td>
                    <td>
                        @if (item.IsApproved)
                        {
                            @Html.ActionLink("Details", "UserStudyDetails", new { sid = item.StudyId, uid = Model.ID })
                        }
                        else if (!item.Waiting)
                        {
                            @Html.ActionLink("Review Approval", "UserSessionDetails", new { initial = true, sid = item.StudyId, uid = Model.ID })
                        }
                        else
                        {
                            @:Waiting for user
                                                                }
                    </td>
                </tr>
            }
        </table>
    }
    else
    { 
        <p>User is not enroled at any study</p>
    }
</fieldset>
<p>
    @Html.ActionLink("Back to userlist", "Index")
</p>
